#include <tsubamegaeshi-base/actionhandler.h>

Actionhandler::Actionhandler()
  : hj_commands_(), uj_commands_(), commands_()
{}

Actionhandler::~Actionhandler()
{}

void
Actionhandler::clear()
{
  commands_ = "";
  hj_commands_.clear();
  uj_commands_.clear();
}

std::string
Actionhandler:: get_commands()
{
  std::stringstream ss("");

  ss << commands_;

  std::map<std::string, double>::const_iterator hc_i = hj_commands_.begin();
  for (; hc_i != hj_commands_.end(); hc_i++) {
    ss << "(" << hc_i->first << " " << hc_i->second << ")";
  }

  std::map<std::string, std::pair<double, double> >::const_iterator uc_i = uj_commands_.begin();
  for (; uc_i != uj_commands_.end(); uc_i++) {
    ss << "(" << uc_i->first << " " << uc_i->second.first << " " << uc_i->second.second << ")";
  }
  return ss.str();
}

void
Actionhandler::scene(const std::string name)
{
  std::stringstream ss("");
  ss << "(scene " << name << ")";
  commands_ += ss.str();
}

void
Actionhandler::init(const std::string name)
{
  std::stringstream ss("");
  ss << "(init (unum 0)(teamname " << name << "))";
  commands_ += ss.str();
}

void
Actionhandler::beam(double x, double y, double angle)
{
  std::stringstream ss("");
  ss << "(beam "
     << x << " "
     << y << " "
     << angle << " )";
  commands_ += ss.str();
}

bool
Actionhandler::lae1_2(double v1, double v2)
{
  uj_commands_["lae1_2"] = std::pair<double, double>(v1, v2);
  return true;
}

bool
Actionhandler::lae3(double v)
{
  hj_commands_["lae3"] = v;
  return true;
}

bool
Actionhandler::lae4(double v)
{
  hj_commands_["lae4"] = v;
  return true;
}

bool
Actionhandler::rae1_2(double v1, double v2)
{
  uj_commands_["rae1_2"] = std::pair<double, double>(v1, v2);
  return true;
}

bool
Actionhandler::rae3(double v)
{
  hj_commands_["rae3"] = v;
  return true;
}

bool
Actionhandler::rae4(double v)
{
  hj_commands_["rae4"] = v;
  return true;
}

bool 
Actionhandler::lle1(double v)
{
  hj_commands_["lle1"] = v;
  return true;
}

bool
Actionhandler::lle2_3(double v1, double v2)
{
  uj_commands_["lle2_3"] = std::pair<double, double>(v1, v2);
  return true;
}

bool
Actionhandler::lle4(double v)
{
  hj_commands_["lle4"] = v;
  return true;
}

bool 
Actionhandler::lle5_6(double v1, double v2)
{
  uj_commands_["lle5_6"] = std::pair<double, double>(v1, v2);
  return true;
}

bool
Actionhandler::rle1(double v)
{
  hj_commands_["rle1"] = v;
  return true;
}

bool
Actionhandler::rle2_3(double v1, double v2)
{
  uj_commands_["rle2_3"] = std::pair<double, double>(v1, v2);
  return true;
}

bool
Actionhandler::rle4(double v)
{
  hj_commands_["rle4"] = v;
  return true;
}

bool
Actionhandler::rle5_6(double v1, double v2)
{
  uj_commands_["rle5_6"] = std::pair<double, double>(v1, v2);
  return true;
}

